package com.itheima.service.impl;

import com.itheima.mapper.CountMapper;
import com.itheima.service.CountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CountServiceImpl implements CountService {


    @Autowired
    private CountMapper countMapper;


    //员工性别统计
    @Override
    public List<Map> genderCount() {
        return countMapper.genderCount();
    }


    //物品类型金额统计
    @Override
    public Map<String, List> salesCount() {
        List<Map> maps = countMapper.salesCount();
        List<Object> productName = maps.stream().map(map -> map.get("product_name")).toList();
        List<Object> num = maps.stream().map(map -> map.get("sum(num)")).toList();
        HashMap<String, List> hashmap = new HashMap();
        hashmap.put("product", productName);
        hashmap.put("num", num);

        return hashmap;
    }

    //会员等级统计
    @Override
    public List<Map> vipCount() {
        return countMapper.vipCount();
    }
}
